<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>业务模块-会员</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="${s.base}/css/base/base.css?123456" media="all" /></head>

<body class="childrenBody">
<form class="layui-form">
    <blockquote class="layui-elem-quote quoteBox" id="tool">
        <div class="layui-inline">
            <!--<label class="layui-input-inline">级别</label>
            <label class="layui-input-inline">
                <select name="grade" id="grade"></select>
            </label>-->
            <label class="layui-input-inline">ID号</label>
            <label class="layui-input-inline">
                <input type="text" class="layui-input" name="cardNo" placeholder="请输入ID号" /></label>
            <label class="layui-input-inline">昵称</label>
            <label class="layui-input-inline">
                <input type="text" class="layui-input" name="nickName" placeholder="请输入昵称" /></label>
            <a class="layui-btn search_btn" lay-submit="" lay-filter="seacherBtn">搜索</a>
            <!--<a class="layui-btn export_btn" lay-submit="" >导出</a>-->
        </div>
    </blockquote>
    <table id="entityList" lay-filter="entityList"></table>
</form>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript">layui.use(['jquery', 'form','pageUtil','dialogUtil', 'fileUtil', 'table', 'dateUtil'],
    function() {
        var $ = layui.jquery,
            dateUtil = layui.dateUtil,
            form = layui.form,
            fileUtil = layui.fileUtil,
            dialogUtil = layui.dialogUtil,
            table = layui.table,
            pageUtil = layui.pageUtil;

        var tableIns = null;
        pageUtil.initDict("web_member_grade",
            function(dictData) {
                //pageUtil.showDict($("#grade"), pageUtil.aceeptDictContentList(dictData, "web_member_grade"), "请选择级别");
                var url = "/webMember/page";
                var cols = [{
                    type: 'checkbox',
                    fixed: 'left'
                },
                    {
                        type: 'numbers',
                        title: '序号'
                    },
                    {
                        field: 'cardNo',
                        title: 'ID号',
                        align: 'center'
                    },
                    {
                        field: 'nickName',
                        title: '昵称',
                        align: 'center'
                    },
                    {field: 'headImage', title: '头像',align:'center', templet:function(d){
                            return "<img lay-event ='showPicture'  src='"+d.headImage+"' style='width:auto; max-width: 96%; height: 40px;'/>";
                        },width:100},
                    {field: 'grade',title: '级别', align:'center', templet:function(d){
                            if(d.grade==null || d.grade == ""){
                                return '普通角色';
                            }else{
                                return pageUtil.aceeptDictContentName(dictData,"web_member_grade",d.grade);
                            }
                        }},
                    {
                        field: 'createTime',
                        title: '创建时间',
                        width: 190,
                        align: 'center',
                        templet: function(d) {
                            return dateUtil.formatDate(new Date(d.createTime), "yyyy-MM-dd HH:mm:ss");
                        }
                    },
                    {
                        title: '操作',
                        width: 220,
                        align: "center",
                        fixed: 'right',
                        templet: function (d) {
                            return '<a class="layui-btn cy-btnbg-edit layui-btn-sm " lay-event="setRecovery"> 设置项目经纪人 </a>';
                        }
                    }];
                tableIns = pageUtil.initDate(cols, url, true);
            });

        // 导出
        $(".export_btn").on("click",function(){
            var cardNo = $("input[name='cardNo']").val();
            var nickName = $("input[name='nickName']").val();
            var name = $("input[name='name']").val();
            window.location.href = "/webMember/export?cardNo="+cardNo+"&nickName="+nickName+"&name="+name;
        });

        table.on('tool(entityList)',
            function(obj) {
                var layEvent = obj.event,
                    data = obj.data;
                if (layEvent === 'edit') {
                    pageUtil.editPopup("编辑", "/webMember/getEntity?id=" + data.id);
                } else if (layEvent === 'showPicture') {
                    fileUtil.imageSingleShow(data.headImage);
                } else if (layEvent === 'setRecovery') {
                    // 设置用户
                    var id = data.id;
                    var grade = data.grade;
                    var name = "";
                    if (data.name != null && data.name != "") {
                        name = data.name;
                    }
                    var phone = "";
                    if (data.phone != null && data.phone != "") {
                        phone = data.phone;
                    }
                    var index = layer.open({
                        type: 1,
                        title:'分配',
                        area: ['500px', 'auto'], //宽高
                        btn:['确定','取消'],
                        content: '<div style="height: 195px;padding: 15px !important;">'+
                        '<form class="layui-form" action="">'+
                        '<div class="layui-form-item layui-row layui-col-xs12">'+
                        '<label class="layui-form-label">'+
                        '<span class="red">*</span>&nbsp;&nbsp;级别</label>'+
                        '<div class="layui-input-block" style="width:300px;">'+
                        '<select class="form-control"  name="grade" lay-verify="required" id="grade"></select>'+
                        '</div>'+
                        '</div>'+
                        '<div class="layui-form-item layui-row layui-col-xs12">'+
                        '<label class="layui-form-label">'+
                        '<span class="red">*</span>&nbsp;&nbsp;姓名</label>'+
                        '<div class="layui-input-block">'+
                        '<input type="text" class="layui-input" style="width:300px;" id="name" name="name" value="'+name+'" lay-verify="required" autocomplete="off" /></div>'+
                        '</div>'+
                        '<div class="layui-form-item layui-row layui-col-xs12">'+
                        '<label class="layui-form-label">'+
                        '<span class="red">*</span>&nbsp;&nbsp;手机号</label>'+
                        '<div class="layui-input-block">'+
                        '<input type="text" class="layui-input" style="width:300px;" id="phone" name="phone" value="'+phone+'"  lay-verify="required" autocomplete="off" /></div>'+
                        '</div>'+
                        '</form>'+
                        '</div>'
                        ,success:function(){
                            pageUtil.initDict("web_member_grade",
                                function(dictData) {
                                    pageUtil.showDict($("#grade"), pageUtil.aceeptDictContentList(dictData, "web_member_grade"), "", grade);
                                });
                        }
                        ,yes:function (){
                            var grade = $("#grade").val();
                            var name = $("#name").val();
                            if (name == null || name == "") {
                                dialogUtil.alert("姓名不能为空");
                                return false;
                            }
                            var phone = $("#phone").val();
                            if (phone == null || phone == "") {
                                dialogUtil.alert("手机号不能为空");
                                return false;
                            }
                            var params={
                                "id":id,
                                "grade":grade,
                                "name":name,
                                "phone":phone
                            }
                            $.post("/webMember/setGrade", params, function (result) {
                                layer.close(index);
                                if (result.code === 0) {
                                    //操作成功
                                    tableIns.reload();
                                } else {
                                    //操作失败
                                    dialogUtil.alert(result.msg);
                                }
                            }, "json");
                        }
                        ,btn2: function(index, layero){

                        }
                    });
                } else if (layEvent === 'del') {
                    pageUtil.delete("确定删除该项吗？", "/webMember/delete", {
                            "id": data.id,
                            "_method": "DELETE"
                        },
                        function(data) {
                            tableIns.reload();
                        });
                }
            });
    })</script>
</body>

</html>